package com.shop.config;

import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Component
@EnableSwagger2
public class SwaggerConfig {



    @Bean
    public Docket adminApiConfig(){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("adminApi")
                .apiInfo(adminApi())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.shop.admincontroller"))
                .build();
    }


    @Bean
    public Docket appApiConfig(){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("appApi")
                .apiInfo(appApi())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.shop.appcontroller"))
                .build();
    }


    @Bean
     private ApiInfo adminApi(){
         return new ApiInfoBuilder()
                 .title("后台开发文档")
                 .description("欢迎学习这套系统，后续我将更新")
                 .version("1.0")
                 .contact(new Contact("黄飞","https://www.kuangstudy.com/bbs/1373155259295236098","2756779610@qq.com"))
                 .license("博客")
                 .licenseUrl("https://www.kuangstudy.com/bbs/1373155259295236098")
                 .build();
     }



    @Bean
    private ApiInfo appApi(){
        return new ApiInfoBuilder()
                .title("商城前端开发文档")
                .description("欢迎学习这套系统，后续我将更新")
                .version("1.0")
                .contact(new Contact("黄飞","https://www.kuangstudy.com/bbs/1373155259295236098","2756779610@qq.com"))
                .license("博客")
                .licenseUrl("https://www.kuangstudy.com/bbs/1373155259295236098")
                .build();
    }
}
